home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 13
/
013.d81
/
think again
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
177 lines
0 gosub61000
1 poke250,0
4 rem in checking black peg may need to times 2nd # by two
5 wd$="qwerty":tg=1:bk$="[157][157][157][157][157][157][157][157]"
6 forcs=54272to54296:pokecs,0:next
10 poke53281,0:print"[147]":dimc$(15)
20 fori=1to15:readc$(i):next
22 ifpeek(250)=1then30
25 input"[147][201]nstructions y[157][157][157]";a$:ifleft$(a$,1)="y"thenpoke250,1:goto8000
30 input"[147][206]umber of colors to choose from";nc:ifnc>15ornc<2then30
31 input"[206]umber of digits in code";nd:ifnd>7ornd<2then31
32 input"[206]umber of guesses";ng:ifng>20orng<2then32
33 print"[147]":gosub5600:fort=1tond:rem code here
34 a=int(14*rnd(.))+1:ifa>ncthen34
35 cd$(t)=mid$(c$(a),2,1)+mid$(c$(a),3,1):na$=na$+mid$(c$(a),1,1):next
40 gosub2020:rem print options
50 gosub900:rem your guess
55 geta$:ifa$=""then55
60 ifval(a$)=0orval(a$)>9then3000
70 yg=val(a$):ifyg>ncthen55
75 ag=ag+1
80 ifyg>ncthenag=ag-1:goto55
90 gs$(ag)=mid$(c$(yg),2,1)+mid$(c$(yg),3,1)
200 rem print number guessed
210 gosub600:ifag=ndthen230
220 goto55
230 geta$:ifa$=""then230
240 ifa$="_"then3000
250 tg=tg+1
299 rem black pegs
300 fork=1tond:af$(k)=cd$(k):next:forir=1tond:ifaf$(ir)="-"then310
305 ifaf$(ir)=gs$(ir)thenbl=bl+1:gs$(ir)="-":af$(ir)="-":gosub4500
310 next
320 ifbl=ndthengoto5000
329 rem white pegs
330 forie=1tond:forot=1tond:ifaf$(ie)="-"then350
340 ifaf$(ie)=gs$(ot)thenwh=wh+1:gs$(ot)="-":af$(ie)="-":gosub4600
350 nextot,ie
400 rem print out pegs
410 printtab(20)"[151]";bl;spc(4)"";wh;spc(4)""wh+bl:iftg=ng+1then6000
420 fort=1tond:gs$(t)="":next:ag=0:bl=0:wh=0:goto50
600 printmid$(c$(yg),2,1)mid$(c$(yg),3,1)spc(7)""mid$(c$(yg),1,1);bk$;
610 poke54296,15:poke54277,0:poke54278,247:poke54276,17:poke54273,yg*10:poke54272,0
620 forg=1to100:next:poke54276,16:return
900 printtg;:iftg<10thenprintspc(2);:return
910 printspc(1);:return
2000 data"1[209]","2[209]","3[159][209]","4[156][209]","5[209]","6[209]","7[158][209]","8[129][209]","9[149][209]","q[150][209]","w[151][209]"
2010 data"e[152][209]","r[153][209]","t[154][209]","y[155][209]"
2020 print"";:fori=1tonc:print""mid$(c$(i),1,1);:next:print"[146]"
2030 fori=1tonc:printmid$(c$(i),2,1);mid$(c$(i),3,1);:next:print"_":return
3000 rem check guess for validity
3005 ifa$="_"andag>0thenag=ag-1:g$=left$(g$,ag):print"[157] [157]"spc(8)" [157][157][157][157][157][157][157][157][157]";:goto4000
3006 ifa$="_"andag=0then55
3007 ifa$="c"thena$=mid$(na$,ag+1,1):fort=1to75:poke53280,t:next:goto60
3008 ifa$="s"then6010
3010 foriu=1to6:ifmid$(wd$,iu,1)=a$thenyg=iu+9:ag=ag+1:goto80
3020 next:goto55
3050 stop
4000 poke54296,15:poke54277,0:poke54278,247:poke54276,33:poke54273,20:poke54272,.
4010 forg=1to100:next:poke54276,32:goto55
4500 poke54296,15:poke54277,0:poke54278,247:poke54276,129:poke54273,255:poke54272,0
4510 forg=1to100:next:poke54276,128:return
4600 poke54296,15:poke54277,0:poke54278,247:poke54276,129:poke54273,20:poke54272,.
4610 forg=1to100:next:poke54276,128:return
5000 gosub7000:print:print"you got it in"tg-1"guesses"
5010 input"play again?";yn$:ifyn$="y"oryn$="yes"thenrun4
5020 ifyn$<>"n"andyn$<>"no"then5010
5030 goto63000: rem end
5600 print:printchr$(142)" # guess guess [151]black white [152]total":return
6000 gosub7500:print:print:print"you ran out of guesses!!![145][145][145]"
6010 print:print"code ";:fori=1tond:printcd$(i)""spc(7)mid$(na$,i,1);bk$;:next
6020 print""
6030 goto5010
6040 :
6050 end
7000 poke54296,15:poke54277,190:poke54278,248:poke54276,17:poke54272,0
7010 fork=1to100:poke54276,17:poke54273,k
7020 poke54276,16:next:return
7500 poke54296,15:poke54277,190:poke54278,248:poke54276,17:poke54272,0
7510 forjk=1to2:poke54276,jk*5:fork=1to20:poke54276,17:poke54273,k
7520 next
7530 fork=20to1step-1:poke54276,17:poke54273,k
7540 poke54276,16:next:next:return
8000 printchr$(142)"[147] this is a game in which the computer"
8005 print"randomly selects a secret code that you"
8010 print"are to guess. its code consists of"
8020 print"colored pegs. naturally, the more"
8030 print"different colored pegs it has to choose"
8040 print"from, the more difficult it is to guess"
8050 print"which colors it has chosen. you are"
8060 print"allowed to specify how many of the 15"
8070 print"possible colors the computer will use.":gosub60000
8080 print"[147]you are also allowed to specify how many"
8090 print"pegs will be used in the code. if four"
8100 print"is selected, the computer will choose"
8110 print"4 colored pegs to be it's secret code."
8120 print"the maximum length of the code is seven"
8130 print"digits long. the secret code would look";
8140 print"something like this-[156][209][209][209][209][151][209][209] if 6"
8150 print"was selected for code length.":gosub60000
8160 print"[147] one other option permits you to "
8170 print"enter and that is how many guesses you"
8180 print"are allowed before you lose. 20 is the"
8190 print"maximum number of guesses you may have"
8200 print"before the computer tells you its code."
8210 :
8220 print"you make your guesses by entering"
8230 print"numbers or letters. when you enter a"
8240 print"character, the character and its"
8250 print"corresponding color will appear next to"
8260 print"the number of the guess you are on.":gosub60000
8270 print"[147]the following table shows what color"
8280 print"will appear for each key."
8290 fori=1to15:print""left$(c$(i),1)" ";right$(c$(i),2):next
8291 print"a similar table is shown at the top of"
8292 print"the playing screen during the game."
8300 gosub60000:
8310 print"[147]if you enter a wrong character, simply"
8320 print"press the _ key and the previous"
8330 print"character is removed. if you wish to"
8340 print"cheat, press the c key and the correct"
8350 print"peg will appear in the spot you are at.":gosub60000
8360 print"[147]be sure to turn the volume up for each"
8370 print"character has its own sound. after you"
8380 print"have typed in the right number of"
8390 print"characters and you are satisfied with"
8400 print"your entry, press any key and your"
8410 print"rating will show up.":gosub60000
8412 print"[147] if a number shows up under the column"
8420 print"headed black, it means you have that"
8430 print"number of pegs that are the right color"
8440 print"and in the right position."
8450 print" if a number shows up under the column"
8460 print"headed white, it means you have that"
8470 print"number of pegs that are the right color,"
8480 print"but in the wrong position."
8490 print"the last column indicates the total"
8500 print"number of white and black pegs."
8505 gosub60000
8510 print"[147] note: black pegs are not included in"
8520 print"the number of white pegs. for example-"
8530 print"if you have a red peg in the right"
8540 print"place you will not get a white peg for"
8550 print"having a right color. a white peg is"
8560 print"given for a peg of the right color but"
8570 print"in the wrong place."
8580 print"if you use up all your guesses the"
8590 print"secret code is revealed.":gosub60000
8600 print"[147]beware: many surprises await you in this";
8610 print"game. try selecting a code of 7 pegs"
8620 print"long and 15 different colors (and dont"
8630 print"use the cheat key)!!"
8640 print" 1. let's play!":print" 2. let's read the instructions again."
8642 print" 3. let's go back to loadstar."
8650 print"which ?"
8651 poke198,0:wait198,1:getz$:
8652 ifval(z$)<1orval(a$)>3thenpoke53280,rnd(1)*10:goto8651
8653 on val(z$)goto30,8000,63000
8660 goto8000
60000 print""spc(12)"<press a key>";
60002 poke198,0:wait198,1:geta$:return
61000 t$=" ":c=0:c$="":print"[147]":poke53281,0
61030 printspc(7)""t$:printspc(7)" [212]hink [193]gain [146]"
61051 printspc(7)""t$:print:printtab(18)"by"
61060 print:printspc(14)"[210]on [195]offen"
61070 print:printspc(12)"[195]opyright 1985"
61080 print:print:print:print" [204][207][193][196][211][212][193][210] is not public domain."
61090 print:print" [208]lease respect the author's rights."
61100 p